<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			function a() {
				var getCheckBox = document.getElementsByTagName("input");
				var j = 0;
				for (var i = 0; i < getCheckBox.length; i++) {
					whichObj = getCheckBox[i];
					if (whichObj.type == "checkbox") {
						if (whichObj.checked == true) {
							j++;
						}
					}
					
				}alert("checkbox 选择个数："+j);
			}
			function selAll() { //全部选中
		var ar = document.getElementsByName("product");
		var a= document.getElementById("s")
		if(s.checked==true){
			for(var i in ar){
				ar[i].checked=true;
			}
		}else{
			for(var i in ar){
				ar[i].checked=false;
			}
		}
	}
		</script>

	</head>
	<body>
		<input type="checkbox" name="but" value="全部" id="s" onclick="selAll()" />全部
		<input type="checkbox" name="product" value="boeing747" />波音747客机
		<br />
		<input type="checkbox" name="product" value="dayaozi" />英国皇家特供大腰子
		<br />
		<input type="checkbox" name="product" value="mazalati" />马萨拉蒂
		<br />
		<input type="checkbox" name="product" value="汤臣一品顶层豪宅" />汤臣一品顶层豪宅客机
		<br />
		<input type="button" value="统计选中个数" onclick="a()" />


	</body>
	</html>
